// 导入登录接口
import { userAccountLogin } from '@/api/user'
const user = {
  namespaced: true,
  state: () => ({
    profile: {}
  }),
  mutations: {
    setUser (state, payload) {
      state.profile = payload
    },
    // 清空数据的函数,恢复成空对象
    emptyData (state) {
      state.profile = {}
    }
  },
  actions: {
    // 拿到数据后调用mutations函数将数据存到state中
    asyncLogin (store, reqData) {
      return new Promise((resolve) => {
        userAccountLogin(reqData).then((res) => {
          store.commit('setUser', res.data.result)
          resolve()
        })
      })
    }
  },
  getters: { }
}
export default user
